package com.example.doctor.jpa;

import cn.hutool.core.date.DateTime;
import com.example.common.entity.HDoctorNotice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;


import java.util.Date;
import java.util.List;

public interface IndexRepository  extends JpaRepository<HDoctorNotice,Long> {

    @Query(value = "SELECT * FROM h_doctor_notice WHERE n_type_tinyint in (0,1) ORDER BY is_top_bit desc,create_time_datetime DESC LIMIT ?1,?2",nativeQuery = true)
    List<HDoctorNotice> noticeList(Integer skip,Integer limit);

    @Query(value = "SELECT count(*) FROM h_doctor_notice WHERE n_type_tinyint in (0,1) ORDER BY is_top_bit desc,create_time_datetime DESC",nativeQuery = true)
    long countNoticeList();

    @Query(value = "SELECT COUNT(*) AS count FROM order_main WHERE dc_id_bigint=?1 AND system_status_tinyint=2 AND a_type_int=?2 AND create_time_datetime>?3",nativeQuery = true)
    Integer onLineCount( Long dcId, Integer aType,  Date date);

    @Query(value = "SELECT COUNT(*) AS count FROM order_main WHERE dc_id_bigint=?1 AND system_status_tinyint=2 AND a_type_int=?2 AND oc_status_tinyint=0 AND create_time_datetime>?3",nativeQuery = true)
    Integer toonLineCount( Long dcId, int aType,  DateTime dateTime);
}
